/**
 * 系统配置信息
 */
import Foundation
import MJRefresh
import UIKit

////////////////////////////////////////////////////////////////////////////////
//MARK:  - 系统配置设置
////////////////////////////////////////////////////////////////////////////////
//包名
let K_APP_BUNDIE_IDENTIFIER = Bundle.main.infoDictionary?["CFBundleIdentifier"]

//App 版本
let K_APP_VERSION = String.init(format:"%@.%@",Bundle.main.infoDictionary!["CFBundleShortVersionString"] as! CVarArg,Bundle.main.infoDictionary!["CFBundleVersion"] as! CVarArg)

//App name
//Bundle.main.infoDictionary?["CFBundleDisplayName"]
let K_APP_NAME = NSLocalizedString("CFBundleDisplayName", tableName: "InfoPlist", bundle: Bundle.main, value: "", comment: "")

//AppId
let K_APP_ID = "000000"


////////////////////////////////////////////////////////////////////////////////
//MARK: - 常量设置
////////////////////////////////////////////////////////////////////////////////
/** 导航栏高度 */
let K_APP_NAVIGATION_BAR_HEIGHT = CGFloat.init(UIDevice.current.isiPhoneX() ? 88 : 64)

/** 导航背景色 */
let K_APP_NAVIGATION_BACKGROUND_COLOR:UIColor = {
    if #available(iOS 13.0, *) {
        let _bc = UIColor.init { (trainCollection:UITraitCollection) -> UIColor in
            if trainCollection.userInterfaceStyle == .dark {
                return UIColor.systemBackground
            }
            return UIColor.white
        }
        return _bc
    }
    return UIColor.white
}()

/**
 * 视图背景色
 * https://www.jianshu.com/p/e6616e44cf60
 * iOS13-适配夜间模式/深色外观
 */
let K_APP_VIEWCONTROLLER_BACKGROUND_COLOR:UIColor = {
    if #available(iOS 13.0, *) {
        let _bc = UIColor.init { (trainCollection:UITraitCollection) -> UIColor in
            if trainCollection.userInterfaceStyle == .dark {
                return UIColor.systemBackground
            }
            return UIColor.white
        }
        return _bc
    }
    return UIColor.white
}()

/** 更多图片 */
let K_APP_MORE_IMAGE:YYImage = {
    if #available(iOS 13.0, *) {
        if UIApplication.shared.keyWindow?.rootViewController!.traitCollection.userInterfaceStyle == .dark {
            return YYImage.init(named: "nav_more_white.png")!
        }
        return YYImage.init(named: "nav_more.png")!
    }
    return YYImage.init(named: "nav_more.png")!
}()

/** 新建视图背景色 */
let K_APP_CREATE_VIEW_BG:UIColor = {
    if #available(iOS 13, *) {
        let _c = UIColor.init { (traitCollection:UITraitCollection) -> UIColor in
            if traitCollection.userInterfaceStyle == .dark {
                return UIColor.systemBackground
            }
            return UIColor.init(hexString: "#F0F1F4")!
        }
        return _c
    }
    return UIColor.init(hexString: "#F0F1F4")!
}()

/** 系统视图宽度 */
let K_APP_WIDTH = UIScreen.main.bounds.size.width

/** 系统视图高度 */
let K_APP_HEIGHT = UIScreen.main.bounds.size.height

/** iPhoneX底部区域 */
let K_APP_IPHONX_BUTTOM = CGFloat.init(34)

/** iPhoneX顶部 导航 区域 */
let K_APP_IPHONX_TOP = CGFloat.init(44)

/** 底部tabbar 高度 */
let K_APP_TABBAR_HEIGHT = CGFloat.init(UIDevice.current.isiPhoneX() ? 82.0 : 48.0)

/** 安全区域 */
let K_APP_SAFETY_HEIGHT = UIDevice.current.isiPhoneX() ? K_APP_IPHONX_BUTTOM : 0.0
let K_APP_SAFETY_NAV_HEIGHT = UIDevice.current.isiPhoneX() ? K_APP_IPHONX_TOP : 20.0

/** 最大文本数字 */
let K_APP_TXT_MAX_LENGTH:Int = 500

////////////////////////////////////////////////////////////////////////////////

//网络连接通知键
let K_APP_IS_NET_WORK = "app_is_net_work_notice_key"
let K_APP_IS_NET_WORK_CODE = "app_is_net_work_code_key"
let K_APP_NO_NETWORK_INFO = "请检测网络链接是否正常"

//app 引导 key
let K_APP_START_GUIDE_VIEW_KEY = "app_start_guide_view"
let K_APP_START_GUIDE_VIEW_HAS_KEY = "app_start_guide_view_has"

/** tbbbar顶部线 */
let K_APP_TABBAR_TOP_LINE = "app_tabbar_top_line"

/** 透明图片 */
let K_APP_TABBAR_CLEARN_IMAGE = "app_tabbar_clearn_image"

/** 默认占位小图 */
let K_APP_DEFAULT_IMAGE_SMALL = "main_none_img_small"

/** 默认占位大图 */
let K_APP_DEFAULT_IMAGE_BIG = "main_none_img_big"

/** 默认用户评论图像 */
let K_APP_DEFAULT_COMMENT_USER_IMAGE = "user_default"

/** 默认用户图像 */
let K_APP_DEFAULT_USER_IMAGE = "mine_default"

/** 图片上传指定的类型 */
let K_UPLOAD_IMAGE_TYPE_SET = "image/jpge,image/gif,image/jpeg,image/png,image/pjpeg"

/** 购物车tag */
let K_APP_CAR_TAG = 123456

/** 顶部多栏菜单tag */
let K_APP_MENU_HEAD_TAG = 1234567


//注模板id在官网后台 SMSSDK产品下的短信模版里面添加（需要申请过自定义短信签名的应用才能添加短信模板,没有可置为空）
//详见：http://wiki.mob.com/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90-11/
let K_APP_PHONE_TEMPLATE_ID = ""

/** 发送验证码倒计时(单位:s) */
let K_APP_CODE_TIMER_COUNT = 180

/** 验证码长度 */
let K_APP_CODE_LENGTH = 6



////////////////////////////////////////////////////////////////////////////////
//MARK: - UI字体、颜色配置信息
////////////////////////////////////////////////////////////////////////////////
/** App主颜色 */
let K_APP_TINT_COLOR = UIColor.init().colorFromHexInt(hex: 0x0079FE)

/** 视图标题颜色 */
let K_APP_VIEWCONTROLLER_TITLE_COLOR = UIColor.init().colorFromHexString(hex: "#333333")

/** 视图标题大小 */
let K_APP_VIEWCONTROLLER_TITLE_FONT = CGFloat.init(18)

/** 列内容视图背景色、兼容夜间模式 */
let K_APP_CELL_BGCOLOR:UIColor = {
    if #available(iOS 13.0, *) {
        let _c = UIColor.init { (traitCollection:UITraitCollection) -> UIColor in
            if traitCollection.userInterfaceStyle == .dark {
                return UIColor.init(hexString: "#2D2D2D")!
            }
            return UIColor.white
        }
        return _c
    }
    return UIColor.white
}()

/** 列选中背景色 */
let K_APP_CELL_SELECT_BGCOLOR:UIColor = {
    if #available(iOS 13.0, *) {
        let _c = UIColor.init { (traitCollection:UITraitCollection) -> UIColor in
            if traitCollection.userInterfaceStyle == .dark {
                return UIColor.init(hexString: "#2D2D2D")!
            }
            return UIColor.init(hexString: "#eff3ff")!
        }
        return _c
    }
    else{
        return UIColor.init(hexString: "#eff3ff")!
    }
}()

/** 分割线颜色 */
let K_APP_SPLIT_LINE_COLOR:UIColor = {
    if #available(iOS 13.0, *) {
        let _c = UIColor.init { (traitCollection:UITraitCollection) -> UIColor in
            if traitCollection.userInterfaceStyle == .dark {
                return UIColor.init().colorFromHexInt(hex: 0x2D2D2D)
            }
            return UIColor.init().colorFromHexInt(hex: 0xE3E3E3)
        }
        return _c
    }
    return UIColor.init().colorFromHexInt(hex: 0xE3E3E3)
}()

/** 分隔条颜色 */
let K_APP_SPLIT_STRIP_COLOR:UIColor = {
    if #available(iOS 13.0, *) {
        let _c = UIColor.init { (traitCollection:UITraitCollection) -> UIColor in
            if traitCollection.userInterfaceStyle == .dark {
                return UIColor.init().colorFromHexInt(hex: 0x2D2D2D)
            }
            return UIColor.init().colorFromHexInt(hex: 0xF2F2F2)
        }
        return _c
    }
    return UIColor.init().colorFromHexInt(hex: 0xF2F2F2)
}()

/** boxView 标题颜色 */
let K_APP_BOXVIEW_TITLE_COLOR:UIColor = {
    if #available(iOS 13.0, *) {
        let _c = UIColor.init { (traitCollection:UITraitCollection) -> UIColor in
            if traitCollection.userInterfaceStyle == .dark {
                return UIColor.white
            }
            return UIColor.black
        }
        return _c
    }
    return UIColor.black
}()

/** 视图阴影颜色 */
let K_APP_VIEW_SHADOW_COLOR = UIColor.init().colorFromHexRGB(r: 145.0/255.0, g: 145.0/255.0, b: 145.0/255.0, alpha: 0.29)

/** 未启用视图颜色 */
let K_APP_VIEW_UNABLE_COLOR = UIColor.init().colorFromHexInt(hex: 0xc5c5c5)

/** 视图阴影透明度 */
let K_APP_VIEW_CELL_SHADOW_OPACITY = Float.init(0.3)

/** 长按时间最小触发时间(单位：秒) */
let K_APP_LONG_MINIMUM_PRESSDURATION:Double = 2


////////////////////////////////////////////////////////////////////////////////
//MARK: - Bugly测试配置信息
////////////////////////////////////////////////////////////////////////////////
let K_APP_BUGLY_APP_ID = ""
let K_APP_BUGLY_APP_KEY = ""


////////////////////////////////////////////////////////////////////////////////
//MARK: - 头都菜单配置信息
////////////////////////////////////////////////////////////////////////////////
//头部选中菜单颜色、默认颜色
let K_HEAD_MENU_SELECT_COLOR = UIColor.init().colorFromHexInt(hex: 0x0289FE)
let K_HEAD_MENU_DEFAULT_COLOR = UIColor.init().colorFromHexInt(hex: 0x999999)

//头部菜单字体
let K_HEAD_MENU_FONT_SIZE = CGFloat.init(15)

//缩放级别
let K_HEAD_MENU_SCALE = CGFloat.init(1.07)

//菜单底部指示线宽度
let K_HEAD_BOTTOM_LINE_WIDTH = CGFloat.init(15)

//菜单底部指示线高度
let K_HEAD_BOTTOM_LINE_HEIGHT = CGFloat.init(2)

//菜单底部指示线颜色
let K_HEAD_BOTTOM_LINE_COLOR = UIColor.init().colorFromHexInt(hex: 0x0079FE)

//MARK: - 发票配置
let K_APP_INVOICE_VALUE = ["ALL","VAT_ORDINARY","VAT_SPECIAL"]
let K_APP_INVOICE_TEXT = ["全部","增值税普通发票","增值税专用发票"]

//MARK: - 京东AI拍照识别
let K_APP_JD_APP_KEY = ""
let K_APP_JD_SECRET_KEY = ""
let K_APP_JD_HOST = "https://aiapi.jd.com/jdai/snapshop"
let K_APP_JD_IMAGE_MAX_SIZE = CGFloat.init(3.75 * 1024) //单位：KB
let K_APP_JD_CHANNEL = "test"

//MARK: - 百度地图配置信息
let K_APP_BDMAP_APP_ID = ""
let K_APP_BDMAP_APP_KEY = ""

//MARK: - 刷新、加载更多
let K_APP_LOADING_INFO = ""

/** MJRefreshGifHeader */
func K_APP_REFRESH_HEADER(refreshBlock:@escaping(()->Void)) -> MJRefreshGifHeader {
    
    let gifH:MJRefreshGifHeader = MJRefreshGifHeader.init()
    
    //隐藏文本
    gifH.stateLabel.isHidden = true
    
    //刷新回调
    gifH.refreshingBlock = refreshBlock
    
    //下拉中
    gifH.setImages([ YYImage.init(named: "gomro20000.png") as Any,
                     YYImage.init(named: "gomro20001.png") as Any,
                     YYImage.init(named: "gomro20002.png") as Any,
                     YYImage.init(named: "gomro20003.png") as Any,
                     YYImage.init(named: "gomro20004.png") as Any,
                     YYImage.init(named: "gomro20005.png") as Any,
                     YYImage.init(named: "gomro20006.png") as Any,
                     YYImage.init(named: "gomro20007.png") as Any,
                     YYImage.init(named: "gomro20008.png") as Any,
                     YYImage.init(named: "gomro20009.png") as Any,
                     YYImage.init(named: "gomro20010.png") as Any,
                     YYImage.init(named: "gomro20011.png") as Any,
                     YYImage.init(named: "gomro20012.png") as Any], for: .pulling)
    
    //即将刷新
    gifH.setImages([ YYImage.init(named: "gomro20000.png") as Any,
                     YYImage.init(named: "gomro20001.png") as Any,
                     YYImage.init(named: "gomro20002.png") as Any,
                     YYImage.init(named: "gomro20003.png") as Any,
                     YYImage.init(named: "gomro20004.png") as Any,
                     YYImage.init(named: "gomro20005.png") as Any,
                     YYImage.init(named: "gomro20006.png") as Any,
                     YYImage.init(named: "gomro20007.png") as Any,
                     YYImage.init(named: "gomro20008.png") as Any,
                     YYImage.init(named: "gomro20009.png") as Any,
                     YYImage.init(named: "gomro20010.png") as Any,
                     YYImage.init(named: "gomro20011.png") as Any,
                     YYImage.init(named: "gomro20012.png") as Any], for: .willRefresh)
    
    //刷新中
    gifH.setImages([ YYImage.init(named: "gomro20000.png") as Any,
                     YYImage.init(named: "gomro20001.png") as Any,
                     YYImage.init(named: "gomro20002.png") as Any,
                     YYImage.init(named: "gomro20003.png") as Any,
                     YYImage.init(named: "gomro20004.png") as Any,
                     YYImage.init(named: "gomro20005.png") as Any,
                     YYImage.init(named: "gomro20006.png") as Any,
                     YYImage.init(named: "gomro20007.png") as Any,
                     YYImage.init(named: "gomro20008.png") as Any,
                     YYImage.init(named: "gomro20009.png") as Any,
                     YYImage.init(named: "gomro20010.png") as Any,
                     YYImage.init(named: "gomro20011.png") as Any,
                     YYImage.init(named: "gomro20012.png") as Any,
                     YYImage.init(named: "gomro20013.png") as Any,
                     YYImage.init(named: "gomro20014.png") as Any,
                     YYImage.init(named: "gomro20015.png") as Any,
                     YYImage.init(named: "gomro20016.png") as Any,
                     YYImage.init(named: "gomro20017.png") as Any,
                     YYImage.init(named: "gomro20018.png") as Any,
                     YYImage.init(named: "gomro20019.png") as Any,
                     YYImage.init(named: "gomro20020.png") as Any,
                     YYImage.init(named: "gomro20021.png") as Any,
                     YYImage.init(named: "gomro20022.png") as Any,
                     YYImage.init(named: "gomro20023.png") as Any,
                     YYImage.init(named: "gomro20024.png") as Any,
                     YYImage.init(named: "gomro20025.png") as Any,
                     YYImage.init(named: "gomro20026.png") as Any,
                     YYImage.init(named: "gomro20027.png") as Any,
                     YYImage.init(named: "gomro20028.png") as Any,
                     YYImage.init(named: "gomro20029.png") as Any,
                     YYImage.init(named: "gomro20030.png") as Any,
                     YYImage.init(named: "gomro20031.png") as Any,
                     YYImage.init(named: "gomro20032.png") as Any], for: .refreshing)
    
    //图片居中
    gifH.gifView.snp.makeConstraints {make in
        let _window:UIWindow = (UIApplication.shared.keyWindow ?? UIApplication.shared.windows.first)!
        make.centerX.equalTo(_window.centerX)
    }
    
    return gifH
}

/** MJRefreshBackGifFooter */
func K_APP_REFRESH_FOOTER(refreshBlock:@escaping(()->Void)) -> MJRefreshBackGifFooter {
 
    let gifH:MJRefreshBackGifFooter = MJRefreshBackGifFooter.init()
    
    //隐藏文本
    //gifH.stateLabel.isHidden = true
    
    //刷新回调
    gifH.refreshingBlock = refreshBlock
    
    //下拉中
    gifH.setImages([ YYImage.init(named: "gomro20000.png") as Any,
                     YYImage.init(named: "gomro20001.png") as Any,
                     YYImage.init(named: "gomro20002.png") as Any,
                     YYImage.init(named: "gomro20003.png") as Any,
                     YYImage.init(named: "gomro20004.png") as Any,
                     YYImage.init(named: "gomro20005.png") as Any,
                     YYImage.init(named: "gomro20006.png") as Any,
                     YYImage.init(named: "gomro20007.png") as Any,
                     YYImage.init(named: "gomro20008.png") as Any,
                     YYImage.init(named: "gomro20009.png") as Any,
                     YYImage.init(named: "gomro20010.png") as Any,
                     YYImage.init(named: "gomro20011.png") as Any,
                     YYImage.init(named: "gomro20012.png") as Any], for: .pulling)
    
    //刷新中
    gifH.setImages([ YYImage.init(named: "gomro20000.png") as Any,
                     YYImage.init(named: "gomro20001.png") as Any,
                     YYImage.init(named: "gomro20002.png") as Any,
                     YYImage.init(named: "gomro20003.png") as Any,
                     YYImage.init(named: "gomro20004.png") as Any,
                     YYImage.init(named: "gomro20005.png") as Any,
                     YYImage.init(named: "gomro20006.png") as Any,
                     YYImage.init(named: "gomro20007.png") as Any,
                     YYImage.init(named: "gomro20008.png") as Any,
                     YYImage.init(named: "gomro20009.png") as Any,
                     YYImage.init(named: "gomro20010.png") as Any,
                     YYImage.init(named: "gomro20011.png") as Any,
                     YYImage.init(named: "gomro20012.png") as Any,
                     YYImage.init(named: "gomro20013.png") as Any,
                     YYImage.init(named: "gomro20014.png") as Any,
                     YYImage.init(named: "gomro20015.png") as Any,
                     YYImage.init(named: "gomro20016.png") as Any,
                     YYImage.init(named: "gomro20017.png") as Any,
                     YYImage.init(named: "gomro20018.png") as Any,
                     YYImage.init(named: "gomro20019.png") as Any,
                     YYImage.init(named: "gomro20020.png") as Any,
                     YYImage.init(named: "gomro20021.png") as Any,
                     YYImage.init(named: "gomro20022.png") as Any,
                     YYImage.init(named: "gomro20023.png") as Any,
                     YYImage.init(named: "gomro20024.png") as Any,
                     YYImage.init(named: "gomro20025.png") as Any,
                     YYImage.init(named: "gomro20026.png") as Any,
                     YYImage.init(named: "gomro20027.png") as Any,
                     YYImage.init(named: "gomro20028.png") as Any,
                     YYImage.init(named: "gomro20029.png") as Any,
                     YYImage.init(named: "gomro20030.png") as Any,
                     YYImage.init(named: "gomro20031.png") as Any,
                     YYImage.init(named: "gomro20032.png") as Any], for: .refreshing)
    
    //图片居中
    gifH.gifView.snp.makeConstraints {make in
        let _window:UIWindow = (UIApplication.shared.keyWindow ?? UIApplication.shared.windows.first)!
        make.centerX.equalTo(_window.centerX)
    }
    
    gifH.stateLabel.snp.makeConstraints {make in
        let _window:UIWindow = (UIApplication.shared.keyWindow ?? UIApplication.shared.windows.first)!
        make.top.equalTo(gifH.gifView.snp.bottom)
        make.centerX.equalTo(_window.centerX)
    }
    
    return gifH
}


//MARK: -
let k_title:String = "title"
let k_icon:String = "icon"
let k_time:String = "time"
let k_data:String = "data"
let k_placehodle = "placehodle"
let k_right:String = "isRight"
let k_code:String = "code"
let k_value:String = "value"
let k_switch:String = "is_switch"
let k_foot:String = "foot"
let k_description:String = "description"
